 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStTicketPettyAddCashDetails;
import com.zdkj.subway.stm.service.SwStTicketPettyAddCashDetailsService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 车站配备用金详情
 *
 * @author songtuo
 * @date 2020-07-09 14:14:41
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstticketpettyaddcashdetails" )
@Api(value = "swstticketpettyaddcashdetails", tags = "车站配备用金详情管理")
public class SwStTicketPettyAddCashDetailsController {

    private final  SwStTicketPettyAddCashDetailsService swStTicketPettyAddCashDetailsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStTicketPettyAddCashDetails 车站配备用金详情
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStTicketPettyAddCashDetailsPage(Page page, SwStTicketPettyAddCashDetails swStTicketPettyAddCashDetails) {
        return R.ok(swStTicketPettyAddCashDetailsService.page(page, Wrappers.query(swStTicketPettyAddCashDetails)));
    }


    /**
     * 通过id查询车站配备用金详情
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStTicketPettyAddCashDetailsService.getById(id));
    }

    /**
     * 新增车站配备用金详情
     * @param swStTicketPettyAddCashDetails 车站配备用金详情
     * @return R
     */
    @ApiOperation(value = "新增车站配备用金详情", notes = "新增车站配备用金详情")
    //@SysLog("新增车站配备用金详情" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyaddcashdetails_add')" )
    public R save(@RequestBody SwStTicketPettyAddCashDetails swStTicketPettyAddCashDetails) {
        return R.ok(swStTicketPettyAddCashDetailsService.save(swStTicketPettyAddCashDetails));
    }

    /**
     * 修改车站配备用金详情
     * @param swStTicketPettyAddCashDetails 车站配备用金详情
     * @return R
     */
    @ApiOperation(value = "修改车站配备用金详情", notes = "修改车站配备用金详情")
    //@SysLog("修改车站配备用金详情" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyaddcashdetails_edit')" )
    public R updateById(@RequestBody SwStTicketPettyAddCashDetails swStTicketPettyAddCashDetails) {
        return R.ok(swStTicketPettyAddCashDetailsService.updateById(swStTicketPettyAddCashDetails));
    }

    /**
     * 通过id删除车站配备用金详情
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车站配备用金详情", notes = "通过id删除车站配备用金详情")
    //@SysLog("通过id删除车站配备用金详情" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('generator_swstticketpettyaddcashdetails_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStTicketPettyAddCashDetailsService.removeById(id));
    }

}
